package ms.platform.system.service;

import ms.platform.system.dao.WorkingProcedureTemplateDAO;
import ms.platform.system.model.WorkingProcedureTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Map;

@Service
@Transactional(propagation = Propagation.SUPPORTS)
public class WorkingProcedureTemplateService {
    @Autowired
    private WorkingProcedureTemplateDAO workingProcedureTemplateDAO;

    /**
     * 获取模板
     *
     * @return
     */
    public List<WorkingProcedureTemplate> getAllWorkingProcedureTemplate(Map<String, Object> map) {
        return workingProcedureTemplateDAO.getAllWorkingProcedureTemplate(map);
    }

    //获取总数
    public Integer queryTemplateCount(Map<String, Object> map) {
        return workingProcedureTemplateDAO.queryTemplateCount(map);
    }

    //获取总数
    public Integer checkCount() {
        Integer count = 0;
        if (workingProcedureTemplateDAO.checkCount() == null || workingProcedureTemplateDAO.checkCount() == 0) {
            count = 1000;
        } else {
            count = workingProcedureTemplateDAO.checkCount();
        }
        return count;
    }

    //获取总数
    public List<WorkingProcedureTemplate> queryCount(WorkingProcedureTemplate template) {
        return workingProcedureTemplateDAO.queryCount(template);
    }

    public void insertBatch(List<WorkingProcedureTemplate> templates) {
        workingProcedureTemplateDAO.insertBatch(templates);
    }

    public List<WorkingProcedureTemplate> queryPageInfo(String code) {
        return workingProcedureTemplateDAO.queryPageInfo(code);
    }

    public void saveTemplates(List<WorkingProcedureTemplate> template) {
        workingProcedureTemplateDAO.saveTemplates(template);
    }

    public void deleteTemplates(Integer id) {
        workingProcedureTemplateDAO.deleteTemplates(id);
    }

    public void deleteCodeTemplates(String code) {
        workingProcedureTemplateDAO.deleteCodeTemplates(code);
    }
}
